<% layout('/layout/default.html', {title: '字典管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-sitemap"></i> 字典管理
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
				<% if(hasPermi('sys:dict:edit')){ %>
					<a href="/sys/dict/form?sort=10" class="btn btn-default btnTool" title="字典添加"><i class="fa fa-plus"></i> 新增</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<form id="searchForm" action="${ctx}/sys/dict/listAll" class="form-inline hide">
				<div class="form-group">
					<label class="control-label">类型：</label>
					<div class="control-inline">
						<select name="type" class="form-control required ">
							<option value="">==请选择==</option>
							<%
								for(str in typeList){
								   print('<option value="'+str+'">'+str+'</option>');
								}
							%>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">描述：</label>
					<div class="control-inline">
						<input name="description" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'键值', name:'value', index:'a.value', width:50, align:"center"},
			{header:'标签', name:'label', index:'a.label', width:100, align:"center"},
			{header:'类型', name:'type', index:'a.type', width:100, align:"center"},
			{header:'描述', name:'description', index:'a.description', width:100, align:"center"},
			{header:'排序', name:'sort', index:'a.sort', width:50, align:"center"},
			{header:'操作', name:'actions', width:50, align:"center",sortable:false, title:false, formatter: function(val, obj, row, act){
				var actions = [];
				<% if(hasPermi('sys:dict:edit')){ %>
					actions.push('<a href="/sys/dict/form?id='+row.id+'" class="btnList" title="编辑字典信息"><i class="fa fa-pencil"></i></a>');
					actions.push('<a href="${ctx}/sys/dict/delete?id='+row.id+'" class="btnList" title="删除字典" data-confirm="确认要删除字典信息吗?"><i class="fa fa-trash-o"></i></a>');
					actions.push('<a href="/sys/dict/form?type='+row.type+'&description='+row.description+'&sort='+(row.sort+10)+'" class="btnList" title="添加键值"><i class="fa fa-plus-square"></i></a>');
				<% } %>
				return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){
			
		}
	});
</script>